

clear

// cd "/Users/tbuser/Dropbox/Real competition/Data/"


import excel "Raw data 2 (for import).xlsx", sheet("Raw data 2") firstrow

rename T Choice11
rename Q8 Choice12
rename Q10 Choice13
rename Q11 Choice14 
rename Q19_PageSubmit Time1
rename Q38_PageSubmit Time2
rename Q61_PageSubmit Time3
rename BU Gender
rename BV Age
rename BW CompetitionScale
rename Q74 RiskScale
rename Q73 Belief
rename Q90 Choice37
			
keep StartDate EndDate Choice11 Choice12 Choice13 Choice14 Time1 Time2 Choice31 Choice32 Choice33 Choice34 Choice35 Choice36 Choice37 Time3 Gender Age CompetitionScale RiskScale Belief Treatment

gen competition1=1 if (Choice11==2& Treatment==1)|(Choice12==2& Treatment==2)|(Choice13==2& Treatment==3)|(Choice14==2& Treatment==4)
replace competition1=0 if (Choice11==1& Treatment==1)|(Choice12==1& Treatment==2)|(Choice13==1& Treatment==3)|(Choice14==1& Treatment==4)

rename Treatment treatment
gen temp=treatment
replace temp=2 if treatment==3
replace temp=3 if treatment==2
replace treatment=temp
drop temp

gen female=Gender==2

rename RiskScale riskscale
rename CompetitionScale competitionscale
rename Belief belief





forv i=1/4 {
 gen treatment`i'=treatment==`i'
 replace treatment`i'=. if treatment==5
 gen treatment`i'fem=treatment`i'*female
}


forvalues i=1(1)6 {
  gen competition3`i'=Choice3`i'==2
}
gen penalty=Choice37==1
replace penalty=. if mi(Choice37)

egen rank2=rank(Time2), field
count
gen chance2=(rank2-1)/(`r(N)'-1)


label define treatment 1 "No impact, forced" 2 "Impact, forced" 3 "No impact, voluntary"  4 "Impact, voluntary" 5 "Comparison group"
label values treatment treatment
label var treatment1 "No impact, forced" 
label var treatment2 "Impact, forced" 
label var treatment3 "No impact, voluntary" 
label var treatment4 "Impact, voluntary"

gen dataset=2



*Drop two participants who did not finish:
drop if mi(Gender)

save "interim", replace

clear

import excel "Raw data (for import).xlsx", sheet("Raw data") firstrow
keep StartDate EndDate Choice11 Choice12 Choice13 Choice14 Time1 Time2 Choice31 Choice32 Choice33 Choice34 Choice35 Choice36 Time3 Gender Age CompetitionScale RiskScale Belief Treatment

gen competition1=1 if (Choice11=="Competition"& Treatment==1)|(Choice12=="Competition"& Treatment==2)|(Choice13=="Competition"& Treatment==3)|(Choice14=="Competition"& Treatment==4)
replace competition1=0 if (Choice11=="Individual pay"& Treatment==1)|(Choice12=="Individual pay"& Treatment==2)|(Choice13=="Individual pay"& Treatment==3)|(Choice14=="Individual pay"& Treatment==4)

rename Treatment treatment
gen temp=treatment
replace temp=2 if treatment==3
replace temp=3 if treatment==2
replace treatment=temp
drop temp

gen female=Gender=="Female"

rename RiskScale riskscale
rename CompetitionScale competitionscale
replace Belief="1" if Belief=="Slowest 10%"
replace Belief="10" if Belief=="Fastest 10%"
destring Belief, gen(belief)




forv i=1/4 {
 gen treatment`i'=treatment==`i'
 replace treatment`i'=. if treatment==5
 gen treatment`i'fem=treatment`i'*female
}


forvalues i=1(1)6 {
  gen competition3`i'=Choice3`i'=="Competition"
}


egen rank2=rank(Time2), field
count
gen chance2=(rank2-1)/(`r(N)'-1)


label define treatment 1 "No impact, forced" 2 "Impact, forced" 3 "No impact, voluntary"  4 "Impact, voluntary" 5 "Comparison group"
label values treatment treatment
label var treatment1 "No impact, forced" 
label var treatment2 "Impact, forced" 
label var treatment3 "No impact, voluntary" 
label var treatment4 "Impact, voluntary"

append using interim.dta, force




gen baselineperformance=Time2/60

replace riskscale=riskscale-1 if dataset==2
replace competitionscale=competitionscale-1 if dataset==2



rename  competition34 temp
rename  competition35 competition34 
rename  temp competition35

label var competition31 "random opp"
label var competition32 "bonus"
label var competition33 "penalty"
label var competition34 "similar opp"
label var competition35 "slower opp"
label var competition36 "faster opp"

gen competitioncount=0
foreach i of numlist 1(1)6 {
	replace competitioncount=competitioncount+1 if competition3`i'==1
}
gen count_equal=competition31+competition34
gen count_disadvantaged=competition33+competition36
gen count_advantaged=competition32+competition35

gen fair= (competition31==1 & competition32==0)|(competition34==1 & competition35==0)
gen inconsistent= (competition33==1 & competition31==0)|(competition36==1 & competition34==0)
replace fair=. if inconsistent==1
gen fair_graphs=fair
replace fair_graphs=fair+2 if fair==0
label define fair_graphs 1 "fair" 2 "self-interested"
label values fair_graphs fair_graphs

gen temp=competition32+competition35
gen competitioncat2=1 if fair==1
replace competitioncat2=2 if competitioncount==0
replace competitioncat2=5 if competitioncount>1 & fair==0
replace competitioncat2=3 if temp==1 & competitioncount==1
replace competitioncat2=4 if temp==2 & competitioncount==2
replace competitioncat2=6 if competitioncount==6
replace competitioncat2=. if inconsistent==1
drop temp
label define competitioncat2  1 "fair" 2 "never" 3 "advantage only (1)" 4 "advantage only (2)" 5 "mixed" 6 "always", replace
label values competitioncat2 competitioncat2


save fairness_and_willingness_to_compete, replace

**Descriptive statistics:

*Table 3
eststo clear
preserve
local variables "chance2 riskscale competitionscale belief female Age"
eststo all: estpost summarize `variables' 
eststo t1: estpost summarize `variables' if treatment==1
eststo t2: estpost summarize `variables' if treatment==2
eststo t3: estpost summarize `variables' if treatment==3
eststo t4: estpost summarize `variables' if treatment==4
eststo t5: estpost summarize `variables' if treatment==5
esttab all t*, cells("mean(pattern(1 1 1 1 1) fmt(2)) b(star pattern(0 0 0 0 0) fmt(2))" /// 
       "sd(pattern(1 1 1 1 1) par fmt(2))  se(pattern(0 0 0 0 0) par fmt(1))") label ///
	   mlabels("all" "T1" "T2" "T3" "T4" "Comp.", nodepvars)
restore

foreach var in `variables' {
	kwallis `var', by(treatment)
}

*Table A1:
eststo clear
preserve
local variables "chance2 riskscale competitionscale belief Age"
eststo t1: estpost summarize `variables' if female==1
eststo t2: estpost summarize `variables' if female==0
esttab t*, cells("mean(pattern(1 1) fmt(2)) b(star pattern(0 0) fmt(2))" /// 
       "sd(pattern(1 1) par fmt(2))  ") label ///
	   mlabels("all" "Women" "Men", nodepvars)
restore

foreach var in `variables' {
	ranksum `var', by(female)
}



*Between-subject experiment:

*Figure 1:
preserve
keep if treatment==1|treatment==2
reg competition1 i.treatment, r
margins treatment
marginsplot, graphregion(color(white)) recast(bar) plotopts(barwidth(0.6)) yscale(r(0)) ylabel(#5) scale(0.9)  name(g1, replace) ytitle("Share competing") title("") xlabel(1 "No impact" 2 "Impact",notick) xtitle("No Choice") nodraw
restore
preserve
keep if treatment==3|treatment==4
reg competition1 i.treatment, r
margins treatment
marginsplot, graphregion(color(white)) recast(bar) plotopts(barwidth(0.6)) yscale(r(0)) ylabel(#5) scale(0.9)  name(g2, replace) ytitle("Share competing") title("") xlabel(3 "No impact" 4 "Impact",notick) xtitle("Choice") nodraw
restore
graph combine g2 g1, graphregion(color(white)) ycommon scale(*1.2)


*Table 4:
preserve
keep if !mi(female )& !mi(riskscale) & !mi(competitionscale) & !mi(belief) & !mi(rank2)
eststo clear
gen treatment_i=treatment==2 if treatment==1 | treatment==2
quietly: eststo: reg competition1 treatment_i, r 
quietly: eststo: reg competition1 treatment_i riskscale belief chance2 female, r 
drop treatment_i
gen treatment_i=treatment==4 if treatment==3 | treatment==4
quietly: eststo: reg competition1 treatment_i, r 
quietly: eststo: reg competition1 treatment_i riskscale belief chance2 female, r 
esttab, noconst star(* 0.1 ** 0.05 *** 0.01) se compress replace label b(3) nonotes nogaps nobaselevels
restore

*Figure A1:
local count=1
local subtitle1 "Men"
local subtitle2 "Women"
foreach cond in "keep if female==0" "keep if female==1" {
preserve
`cond'
keep if treatment==1|treatment==2
reg competition1 i.treatment, r
margins treatment
marginsplot, graphregion(color(white)) recast(bar) plotopts(barwidth(0.6)) yscale(r(0)) ylabel(0(0.2)0.6) scale(0.9)  name(g1, replace) ytitle("Share competing") title("") xlabel(1 "No impact" 2 "Impact",notick) xtitle("No Choice") nodraw
restore
preserve
`cond'
keep if treatment==3|treatment==4
reg competition1 i.treatment, r
margins treatment
marginsplot, graphregion(color(white)) recast(bar) plotopts(barwidth(0.6)) yscale(r(0)) ylabel(0(0.2)0.6) scale(0.9)  name(g2, replace) ytitle("Share competing") title("") xlabel(3 "No impact" 4 "Impact",notick) xtitle("Choice") nodraw
restore
graph combine g2 g1, graphregion(color(white)) ycommon nodraw name(gg`count', replace) subtitle("`subtitle`count''")
local ++count
	
}   
graph combine gg1 gg2, row(3) graphregion(color(white)) ysize(6) ycommon scale(*1.2)


*Table A2:
preserve
keep if !mi(female )& !mi(riskscale) & !mi(competitionscale) & !mi(belief) & !mi(rank2)
eststo clear
quietly: eststo: reg competition1 treatment4 treatment1 treatment2 female, r 
quietly: eststo: reg competition1 treatment4 treatment4fem treatment1 treatment1fem  treatment2 treatment2fem  female, r 
quietly: eststo: reg competition1 treatment4 treatment1 treatment2 female riskscale belief chance2, r 
quietly: eststo: reg competition1 treatment4 treatment4fem treatment1 treatment1fem  treatment2 treatment2fem  female riskscale belief chance2, r 
esttab, noconst star(* 0.1 ** 0.05 *** 0.01) se compress replace label b(3) nonotes nogaps nobaselevels order(competition1 treatment4 treatment4fem treatment1 treatment1fem  treatment2 treatment2fem  female riskscale belief chance2)
restore





*Within-subject experiment:

*Figure 2:
preserve
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision<=3
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)0.8) ///
			 xtitle("Evenness of playing field") name(graph1, replace) nodraw
restore
preserve
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision>=4
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)0.8) ///
			 xtitle("Equality of match") name(graph2, replace) nodraw
restore
graph combine graph1 graph2, rows(1) graphregion(color(white))  ycommon name(g, replace) nodraw
graph display g, ysize(5) xsize(10) scale(1.3)


**Table 5:
eststo clear
preserve
gen id=_n
gen baselinecompetition=competition31
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision<=3
xtset id decision
quietly: eststo: xtreg competition3 i.decision, fe cl(id)
quietly: eststo: xtreg competition3 i.decision if baselinecompetition==1, fe cl(id)
quietly: eststo: xtreg competition3 i.decision if baselinecompetition==0, fe cl(id)
restore
esttab, star(* 0.1 ** 0.05 *** 0.01) label se compress replace  b(3) nonotes nogaps nobaselevels
eststo clear
preserve
gen id=_n
gen baselinecompetition=competition34
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision>3
xtset id decision
quietly: eststo: xtreg competition3 i.decision, fe cl(id)
quietly: eststo: xtreg competition3 i.decision if baselinecompetition==1, fe cl(id)
quietly: eststo: xtreg competition3 i.decision if baselinecompetition==0, fe cl(id)
restore
esttab, star(* 0.1 ** 0.05 *** 0.01) label se compress replace  b(3) nonotes nogaps nobaselevels



*In-text proportions of competition classification:
tab fair
tab competitioncat2


*Figure 3:
local cont "i.treatment"
eststo clear
preserve
keep if !mi(penalty)
eststo: reg penalty i.fair_graphs `cont', r
margins, at(fair_graphs=(1(1)2))
marginsplot, recast(bar) plotopts(barwidth(0.5)) scale(0.8) ylabel(0(0.2)1) ///
             graphregion(color(white)) title("") ytitle("Share imposing penalty", size(*1.5))  ///
			 xtitle("") xlabel(,notick labsize(*1.5)) name(g1, replace) 
restore
local cont "i.treatment"
eststo clear
preserve
keep if !mi(penalty)
eststo: reg penalty i.competitioncat2 `cont', r
margins, at(competitioncat2=(1(1)6))
marginsplot, recast(bar) plotopts(barwidth(0.5)) scale(0.8) ylabel(0(0.2)1) ///
             graphregion(color(white)) title("") ytitle("Share imposing penalty", size(*1.5))  ///
			 xtitle("") xlabel(,alternate notick labsize(*1.5)) name(g1, replace) 
restore



*Table 6:
preserve
eststo clear
keep if !mi(competitionscale)
eststo: reg penalty count_equal count_advantaged count_disadvantaged 
eststo: reg penalty female riskscale competitionscale baselineperfo belief
eststo: reg penalty count_equal count_advantaged count_disadvantaged female riskscale competitionscale baselineperfo belief
eststo: reg penalty count_equal count_advantaged count_disadvantaged female riskscale competitionscale baselineperfo belief i.treatment
esttab, noconst star(* 0.1 ** 0.05 *** 0.01) se compress replace label b(3) nonotes nogaps nobaselevels 
eststo clear
restore



*Figure A2:
reg competition31 i.belief
margins belief
marginsplot, recast(bar) graphregion(color(white)) plotopts(barwidth(0.95)) title("") ytitle("Share competing") xtitle("Confidence (believed performance decile)") ylabel(0(0.25)1)


*Figure A3:
local title1 "Random opponent"
local title2 "With bonus"
local title3 "With penalty"
local title4 "Similar opponent"
local title5 "Slower opponent"
local title6 "Faster opponent"
foreach i of numlist 1(1)6 {
reg competition3`i' i.female, r
margins female
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") subtitle("`title`i''")  ///
		     xlabel(0 "Male" 1 "Female") ytitle("Share competing")  ///
			 xtitle("") nodraw name(g`i', replace)
}
graph combine g1 g2 g3 g4 g5 g6, rows(2) graphregion(color(white))  ycommon iscale(0.7)


*Figure A4:
*Participants who compete in the baseline condition:
preserve
keep if competition31==1
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision==2|decision==3
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)1) ///
			 xtitle("Evenness of playing field") name(graph1, replace) nodraw
restore
preserve
keep if competition34==1
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision==5|decision==6
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)1) ///
			 xtitle("Equality of match") name(graph2, replace) nodraw
restore
graph combine graph1 graph2, rows(1) graphregion(color(white))  ycommon 

*Participants who choose individual incentives in the baseline condition:
preserve
keep if competition31==0
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision==2|decision==3
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)1) ///
			 xtitle("Evenness of playing field") name(graph1, replace) nodraw
restore
preserve
keep if competition34==0
gen id=_n
reshape long competition3, i(id) j(decision)
label define decision 1 "Random opponent" 2 "With bonus" 3 "With penalty" 4 "Similar opponent" 5 "Slower opponent" 6 "Faster opponent"
label values decision decision
keep if decision==5|decision==6
xtset id decision
quietly: eststo: xtreg competition3 i.decision `cond', fe cl(id)
margins decision
marginsplot, recast(bar) plotopts(barwidth(0.6)) ///
             graphregion(color(white)) title("") ///
		     ytitle("Share competing") ylabel(0(0.1)1) ///
			 xtitle("Equality of match") name(graph2, replace) nodraw
restore
graph combine graph1 graph2, rows(1) graphregion(color(white))  ycommon 



*Figure A5:
preserve
quietly: replace fair_graphs=fair_graphs-0.05 if female==0
quietly: replace fair_graphs=fair_graphs+0.05 if female==1
twoway histogram fair_graphs if female==0, discrete color(navy%60) barwidth(0.7) fraction || histogram fair_graphs if female==1,  discrete color(maroon%60) barwidth(0.7) fraction ytitle("Fraction") ylabel(0(0.2)1) legend(order(1 "Male" 2 "Female") position(11) ring(0) col(1)) graphregion(color(white)) xtitle("") name(g2,replace) xla(1/2, valuelabel noticks) 
restore
preserve 
quietly: replace competitioncat2=competitioncat2-0.05 if female==0
quietly: replace competitioncat2=competitioncat2+0.05 if female==1
twoway histogram competitioncat2 if female==0, discrete color(navy%60) barwidth(0.7) fraction || histogram competitioncat2 if female==1,  discrete color(maroon%60) barwidth(0.7) fraction ytitle("Fraction") ylabel(0(0.1)0.5) legend(order(1 "Male" 2 "Female") position(11) ring(0) col(1)) graphregion(color(white)) xtitle("") name(g2,replace) xla(1/6, valuelabel noticks alternate) 
restore


*Figure A6:
preserve
gen i_compete=1 if competitionscale<=6 & !mi(competitionscale)
replace i_compete=3 if competitionscale>8 & !mi(competitionscale)
replace i_compete=2 if mi(i_compete) & !mi(competitionscale)
quietly: replace competitioncat2=competitioncat2-0.1 if i_compete==1
quietly: replace competitioncat2=competitioncat2+0.1 if i_compete==3
twoway histogram competitioncat2 if i_compete==1, discrete color(navy%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==2,  discrete color(maroon%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==3,  discrete color(forest_green%60) barwidth(0.5) fraction ytitle("Fraction") ylabel(0(0.2)0.7) legend(order(1 "Low competitiveness" 2 "Medium competitiveness" 3 "High competitiveness") position(2) ring(0) col(1)) graphregion(color(white)) xtitle("") xla(1/6, valuelabel noticks alternate) 
reg fair i.i_compete if competition31==1|competition34==1
restore
preserve
gen i_risk=1 if risk<=4 & !mi(risk)
replace i_risk=3 if risk>6 & !mi(risk)
replace i_risk=2 if mi(i_risk) & !mi(risk)
quietly: replace competitioncat2=competitioncat2-0.1 if i_risk==1
quietly: replace competitioncat2=competitioncat2+0.1 if i_risk==3
twoway histogram competitioncat2 if i_risk==1, discrete color(navy%60) barwidth(0.5) fraction || histogram competitioncat2 if i_risk==2,  discrete color(maroon%60) barwidth(0.5) fraction || histogram competitioncat2 if i_risk==3,  discrete color(forest_green%60) barwidth(0.5) fraction ytitle("Fraction") ylabel(0(0.2)0.7) legend(order(1 "Low risk seeking" 2 "Medium risk seeking" 3 "High risk seeking") position(2) ring(0) col(1)) graphregion(color(white)) xtitle("") xla(1/6, valuelabel noticks alternate) 
reg fair i.i_risk if competition31==1|competition34==1
restore
preserve
gen i_compete=1 if belief<=4 & !mi(belief)
replace i_compete=3 if belief>7 & !mi(belief)
replace i_compete=2 if mi(i_compete) & !mi(belief)
quietly: replace competitioncat2=competitioncat2-0.1 if i_compete==1
quietly: replace competitioncat2=competitioncat2+0.1 if i_compete==3
twoway histogram competitioncat2 if i_compete==1, discrete color(navy%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==2,  discrete color(maroon%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==3,  discrete color(forest_green%60) barwidth(0.5) fraction ytitle("Fraction") ylabel(0(0.2)0.7) legend(order(1 "Low belief" 2 "Medium belief" 3 "High belief") position(2) ring(0) col(1)) graphregion(color(white)) xtitle("") xla(1/6, valuelabel noticks alternate) 
reg fair i.i_compete if competition31==1|competition34==1
restore
preserve
gen i_compete=1 if rank2<=134 & !mi(rank2)
replace i_compete=3 if rank2>268 & !mi(rank2)
replace i_compete=2 if mi(i_compete) & !mi(rank2)
quietly: replace competitioncat2=competitioncat2-0.1 if i_compete==1
quietly: replace competitioncat2=competitioncat2+0.1 if i_compete==3
twoway histogram competitioncat2 if i_compete==1, discrete color(navy%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==2,  discrete color(maroon%60) barwidth(0.5) fraction || histogram competitioncat2 if i_compete==3,  discrete color(forest_green%60) barwidth(0.5) fraction ytitle("Fraction") ylabel(0(0.2)0.7) legend(order(1 "Low performance" 2 "Medium performance" 3 "High performance") position(2) ring(0) col(1)) graphregion(color(white)) xtitle("") xla(1/6, valuelabel noticks alternate) 
tab i_compete
restore




*Table A3:

*Table A2:
capt prog drop appendmodels
*! version 1.0.0  14aug2007  Ben Jann
program appendmodels, eclass
    // using first equation of model
    version 8
    syntax namelist
    tempname b V tmp
    foreach name of local namelist {
        qui est restore `name'
        mat `tmp' = e(b)
        local eq1: coleq `tmp'
        gettoken eq1 : eq1
        mat `tmp' = `tmp'[1,"`eq1':"]
        local cons = colnumb(`tmp',"_cons")
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1,1..`cons'-1]
        }
        mat `b' = nullmat(`b') , `tmp'
        mat `tmp' = e(V)
        mat `tmp' = `tmp'["`eq1':","`eq1':"]
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
        }
        capt confirm matrix `V'
        if _rc {
            mat `V' = `tmp'
        }
        else {
            mat `V' = ///
            ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
            ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
        }
    }
    local names: colfullnames `b'
    mat coln `V' = `names'
    mat rown `V' = `names'
    eret post `b' `V'
    eret local cmd "whatever"
end

eststo clear
local xlist "competitionscale riskscale belief chance2 female"
foreach i of numlist 1(1)6 {
	local estlist ""
	foreach x in `xlist' {
		quietly: eststo `x'`i':reg competition3`i' `x', r
		local estlist "`estlist' `x'`i'"
	}
	quietly: eststo a`i': appendmodels `estlist'
	quietly: eststo b`i': reg competition3`i' `xlist', r
}
esttab a1 b1 a2 b2 a3 b3, star(* 0.1 ** 0.05 *** 0.01) label se compress replace  b(3) nonotes nogaps nobaselevels noconst
esttab a4 b4 a5 b5 a6 b6, star(* 0.1 ** 0.05 *** 0.01) label se compress replace  b(3) nonotes nogaps nobaselevels noconst






